﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ContactCRUD.Classes
{
    public static class UploadHelper
    {
        public static string UploadContactImage(string fileName,string fullPath)
        {
            /*System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            // compose the name of the image
            byte[] hasData = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(DateTime.Now.ToString() + fileName));
            System.Text.StringBuilder nameBuilder = new System.Text.StringBuilder();
            foreach (byte dataByte in hasData)
            {
                nameBuilder.Append(dataByte.ToString("x2").ToLower());
            }
            // prepare the file 
            //HttpPostedFile File = fileup.PostedFile;
            //byte[] data = new byte[File.ContentLength];
            //File.InputStream.Read(data, 0, data.Length);
            string FileExcention = System.IO.Path.GetExtension(fileup.FileName);

            // build the full name of the file
            nameBuilder.Append(FileExcention);

            try
            {
               // System.IO.FileStream fileStream = new System.IO.FileStream(Request.ServerVariables["APPL_PHYSICAL_PATH"] + "\\PublicFiles\\" + nameBuilder.ToString(), System.IO.FileMode.OpenOrCreate);
               // fileStream.Write(data, 0, data.Length);
               // fileStream.Close();
                string path = Environment.CurrentDirectory + nameBuilder.ToString();
                
                 
                return nameBuilder.ToString();
            }
            catch
            {
                return "";
            }*/
            return null;
        }
    }
}
